package c2.advanced.business.demo.handler;

import c2.advanced.business.base.AdvancedSubModule;
import cate.common.game.mail.MailCmd;
import cate.common.table.d.GDOperation;
import lombok.extern.slf4j.Slf4j;

import static c2.advanced.server.controller.ControllerTool.R;

@Slf4j
public class DemoMailHandler extends AdvancedSubModule {

    public Object doMailSendToGame(int demo) {
        return R(() -> {
            switch (demo) {
                case 1: return demo1();
                case 2: return demo2();
            }
            return "不支持的演示案例序号："+demo;
        });
    }

    private Object demo1() {
        MailCmd m = new MailCmd().withRoleMode(MailCmd.ROLE_MODE_ONLINE).withSrvId(210)
                .withTitle("勇者赛开始啦").withContent("来参加吧！").withReward("0:1:1")
                .withOpr(GDOperation.DEMO).withLifetime(MailCmd.LIFETIME_ONE_HOUR);
        useCommon().sendMail(m);
        return "演示1：发送给该游戏服内的所有在线玩家";
    }

    private Object demo2() {
        // 621de6cde66b611009a6c292  247 gg
        // 641d568139ee65015e465bbc 16120 gg1
        // 6417fbd0e94db36b842e983e 134162 gg00008
        MailCmd m = new MailCmd().withSrvId(210)
                .withTitle("恭喜").withContent("获得前三名奖励").withReward("0:0:4")
                .addRole("621de6cde66b611009a6c292").addRole("641d568139ee65015e465bbc").addRole("6417fbd0e94db36b842e983e")
                .withOpr(GDOperation.NULL, 1001);
        useCommon().sendMail(m);
        return "演示2:发送给该游戏服内指定的三位玩家";
    }

}
